package main

import (
	"fmt"
)

type user struct {
	name     string
	password string
}
type student struct {
	name string
	age  int
}

func main() {
	/*a := user{name: "wang", password: "1024"}
	b := user{"wang", "1024"}
	c := user{name: "wang"}
	c.password = "1024"
	var d user
	d.name = "wang"
	d.password = "1024"

	fmt.Println(a, b, c, d)                 // {wang 1024} {wang 1024} {wang 1024} {wang 1024}
	fmt.Println(checkPassword(a, "haha"))   // false
	fmt.Println(checkPassword2(&a, "haha")) // false*/

	a := student{name: "wang", age: 23}
	b := student{name: "c", age: 24}
	c := student{name: "d", age: 22}
	c.age = 10

	var d student
	d.name = "wang"
	d.age = 99

	fmt.Println(a, b, c, d)
	fmt.Println(checkAge(a, 333))
	setName(a, "Cccccc")
	fmt.Println(a)
	setName2(&a, "Bbbbbb")
	fmt.Println(a)
}

func checkAge(s student, age int) bool {
	return s.age < age
}

func setName(s student, name string) {
	s.name = name
}
func setName2(s *student, name string) {
	s.name = name
}

func checkPassword(u user, password string) bool {
	return u.password == password
}

func checkPassword2(u *user, password string) bool {
	return u.password == password
}
